using System;
using System.Collections.Generic;

using Taimila.Entify.Attributes;

namespace Taimila.Entify.UnitTests
{
	[Entity(Version = 1.0)]
	public class GroupTestEntity : Entity
	{
		[EntityProperty(PersistentName = "Name")]
		public string Name
		{
			get;
			set;
		}
		
		private List<ContactTestEntity> contacts;
		#pragma warning disable
		private List<long?> contactsLazyLoadIdentifiers;
		#pragma warning restore
		[EntityProperty(PersistentName = "Contacts", Relationship = true)]
		public List<ContactTestEntity> Contacts
		{
			get
			{
				if(this.contacts == null && this.contactsLazyLoadIdentifiers == null)
				{
					this.contacts = new List<ContactTestEntity>();	
				}
				
				if(this.contacts == null)
				{
					this.contacts = this.LazyLoadEntities<ContactTestEntity>(this.contactsLazyLoadIdentifiers);
				}
				
				return this.contacts;
			}
			set
			{
				if(value == null)
				{
					throw new ArgumentNullException("Entity relation container cannot be set null. Use Clear() to remove all relations.");
				}
				else
				{
					this.contacts = value;
				}
			}
		}
	}
}
